﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class werpon : MonoBehaviour
{
   //public float spd=1.0f;
    bool exist=true;
    [SerializeField]
    private CanvasGroup grp;
    [SerializeField]
    private float attackSpd;

    // Update is called once per frame
    void Update()
    {
        Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
        Vector3 dir = Input.mousePosition - pos;
        float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
        if(Input.GetKeyDown(KeyCode.Z))
        {
            if (exist == true)
            {
                grp.alpha = 0;
                this.gameObject.SetActive(false);
                exist = false;
            }

            if (exist == false)
            {
                grp.alpha = 1;
                this.gameObject.SetActive(false);
                exist = true;
            }
        }
        transform.position = grp.transform.position;
    }
}
